<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>My JSP 'listCustoms.jsp' starting page</title>



</head>

<body>
	<form id="f1" action="${pageContext.request.contextPath}/servlet/DelMuitiCustom" method="post">
	<table width="80%" border="0">

		<tr>
			<td><a href="addCustom.jsp">添加</a>&nbsp;&nbsp;<a href="javascript:delMult()">删除</a>
			</td>
		</tr>
		<tr>
			<td><c:if test="${empty page.records}">
    				对不起，没有任何信息。
    				
   				 </c:if> 
   				 <c:if test="${!empty page.records}">
					<table border="1" width="100%">
						<tr>
							<th>选择</th>
							<th>姓名</th>
							<th>性别</th>
							<th>生日</th>
							<th>电话</th>
							<th>邮箱</th>
							<th>爱好</th>
							<th>类型</th>
							<th>描述</th>
							<th>操作</th>
						</tr>
						<c:forEach items="${page.records}" var="c" varStatus="vs">
							<tr bgcolor="${vs.index%2==0?'#c9c9c9':'#d7d7d7' }">
								<td><input type="checkbox" name="ids" value="${c.id}" /></td>
								<td>${c.name}</td>
								<td>${c.gender=='1'?'男':'女' }</td>
								<td>${c.birthday }</td>
								<td>${c.cellphone }</td>
								<td>${c.email }</td>
								<td>${c.hobby }</td>
								<td>${c.type }</td>
								<td>${c.description }</td>
								<td><a href="${pageContext.request.contextPath}/servlet/UpdateCustom?id=${c.id}">修改</a>&nbsp;&nbsp;<a href="javascript:delOne('${c.id }')">删除</a></td>
							</tr>
						</c:forEach>

					</table>

				</c:if></td>
		</tr>
		<tr><td align="center">
			<%@include file="/commons/page.jsp" %>
		</td></tr>
	</table>
	</form>
	<script type="text/javascript">
		function delOne(id){
		 var sure=window.confirm("确定删除？");
		 if(sure){
		 	window.location.href="${pageContext.request.contextPath}/servlet/DelOneCustom?id="+id;
		 }
		}
		function delMult(){
			var idsobj=document.getElementsByName("ids");
			
			var issel=false;
			for ( var i = 0; i < idsobj.length; i++) {
				if (idsobj[i].checked) {
					issel=true;
					break;
				}
			}
			
			if (issel) {
				 var sure=window.confirm("确定删除？");
				 if(sure){
				 	document.getElementById("f1").submit();
				 }
			}else{
				alert("请选择记录");
			}
		}
	</script>


</body>
</html>
